home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
501-525
/
disk_519
/
avlsort
/
avltree.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
2KB
|
97 lines
/*
* avltree.h Definitions for avl routines
*
* Copyright 1988 Zinn Computer Company
* by Mark E. Mallett
* All Rights Reserved
*
* This software may be used at will, provided that all credits
* and style be left in place, and that its distribution is not
* restricted. Bug fixes and improvements are welcomed, please
* send these back to me at mem@zinn.MV.COM
*
* rlp910619 -- sorry, I've modified this to include prototypes
* and register arguments.
*/
#ifndef AVLTREE_H /* prevent multiple inclusions */
#define AVLTREE_H
/*--------------------------------------------------------------
* rlp919417 -- Support for Lattice-style register arguments
*--------------------------------------------------------------
*/
#ifndef LATTICE
#define __regargs
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif /*TRUE*/
#ifndef NULL
#define NULL 0L
#endif /*NULL*/
#ifndef NUL
#define NUL '\0'
#endif /*NUL*/
/*-------------------------------------------
* rlp900624 -- added typedefs and prototypes
*-------------------------------------------
*/
typedef struct _AVLNODE AVLNODE;
typedef struct _AVLTREE AVLTREE;
AVLNODE * __regargs avlfind (AVLTREE * treeP, void *keyP);
int __regargs avlinsert (AVLTREE * treeP, void *keyP, void *dataP);
int __regargs avldelete (AVLTREE * treeP, void *keyP);
/* Structures */
/*
* Structure of an avl tree node. Note that this node is meant to be
* used as a header or component of an application-specific structure,
* since there is no key or data information present in the avlnode
* structure.
*/
typedef struct _AVLNODE
{
AVLNODE *n_leftP; /* Ptr to left subtree */
AVLNODE *n_rightP; /* Ptr to right subtree */
int n_balance; /* Balance count */
} AVLNODE;
/*
* Header for an AVL tree.
*/
typedef struct _AVLTREE
{
/*
* Tree parameters
* t_rootP -- pointer to root node
*/
AVLNODE *t_rootP;
/*
* Handler functions for the tree
* t_cmprtc -- Compare two keys
* t_mknode -- Create a node
* t_rmnode -- Destroy a node
*/
int (* __regargs t_cmprtc) (void*, AVLNODE*);
AVLNODE *(* __regargs t_mknode) (AVLTREE*, void*, void*, AVLNODE*);
void (* __regargs t_rmnode) (AVLTREE*, AVLNODE*);
} AVLTREE;
#endif /*AVLTREE_H*/